<h2>Articles</h2>
<div class="error">@Request.QueryString["errorMessage"]</div>
<div class="success">@Request.QueryString["successMessage"]</div>

@if(PageData["Articles"].Count <=0){
<div>No article yet, <a href="@Href("~/Actions/Admin/AddArticle")">Add a new article</a></div>
}else{
<table>
    <thead>
        <th><a href="@Href("~/Actions/Admin/ListAllArticles",new{orderBy="title" , SortBy=PageData["SortBy"]})">Article title</a></th>
        <th><a href="@Href("~/Actions/Admin/ListAllArticles",new{orderBy="category", SortBy=PageData["SortBy"]})">Category</a></th>
        <th><a href="@Href("~/Actions/Admin/ListAllArticles",new{orderBy="creationDate", SortBy=PageData["SortBy"]})">Creation date</a></th><th colspan="4">Actions</th></thead>
<tbody>
@foreach(var Article in PageData["Articles"])
{
    <tr><td title="@Article.summary"><a href="@Href("~/Actions/Admin/ShowArticle",@Article.id)">
        @Article.title
	</a></td><td>@Article.categoryName</td>
        <td>@Article.creationDate.Year/@Article.creationDate.Month/@Article.creationDate.Day</td>
        <td><a href="@Href("~/Actions/Admin/EditArticle/")@Article.id">Edit</a></td>           
        <td ><a href="@Href("~/Actions/Admin/DeleteArticle/")@Article.id">Delete</a></td>
        <td ><a href="@Href("~/Actions/Admin/PublishArticle/")@Article.id">@(Article.published==1?"unpublish":"publish")</a></td>
        <td ><a href="@Href("~/Actions/Admin/EditAllComments/")@Article.id">Comments</a></td>
    </tr>
}
</tbody>
</table>
}

